<?php defined('SYSPATH') OR die('No direct access allowed.'); ?>
<?php echo $cabecalho; ?>
<?php echo $menu; ?>
<!-- Required CSS --> 
	<?php echo html::link('media/treeview/assets/skins/sam/treeview.css', 'stylesheet', 'text/css');?> 
	<!-- Optional CSS for for date editing with Calendar--> 
	<?php echo html::link('media/calendar/assets/skins/sam/calendar.css', 'stylesheet', 'text/css');?>
	 
	<!-- Dependency source file -->  
	<?php echo html::script('media/yahoo-dom-event/yahoo-dom-event.js');?> 
	<!-- Optional dependency source file -->  
	<?php echo html::script('media/animation/animation-min.js');?> 
	<!-- Optional dependency source file for date editing with Calendar-->
	<?php echo html::script('media/calendar/calendar-min.js');?>  
	<!-- Optional dependency source file to decode contents of yuiConfig markup attribute-->
	<?php echo html::script('media/json/json-min.js');?>  
	<!-- TreeView source file -->  
	<?php echo html::script('media/treeview/treeview-min.js');?>
	
<script>
//global variable to allow console inspection of tree:
var tree;

//anonymous function wraps the remainder of the logic:
(function() {

	//function to initialize the tree:
    function treeInit() {
        buildRandomTextNodeTree();
		//handler for expanding all nodes
		YAHOO.util.Event.on("expand", "click", function(e) {
			YAHOO.log("Expanding all TreeView  nodes.", "info", "example");
			tree.expandAll();
			YAHOO.util.Event.preventDefault(e);
		});
		
		//handler for collapsing all nodes
		YAHOO.util.Event.on("collapse", "click", function(e) {
			YAHOO.log("Collapsing all TreeView  nodes.", "info", "example");
			tree.collapseAll();
			YAHOO.util.Event.preventDefault(e);
		});
        
    }
    
	//Function  creates the tree and 
	//builds between 3 and 7 children of the root node:
    function buildRandomTextNodeTree() {
	
		//instantiate the tree:
        tree = new YAHOO.widget.TreeView("treeDiv1");

		<?php echo $arvoreYahoo; ?>

       // Expand and collapse happen prior to the actual expand/collapse,
       // and can be used to cancel the operation
       tree.subscribe("expand", function(node) {
              YAHOO.log(node.index + " was expanded", "info", "example");
              // return false; // return false to cancel the expand
           });

       tree.subscribe("collapse", function(node) {
              YAHOO.log(node.index + " was collapsed", "info", "example");
           });

       // Trees with TextNodes will fire an event for when the label is clicked:
       tree.subscribe("labelClick", function(node) {
              YAHOO.log(node.index + " label was clicked", "info", "example");
           });

		//The tree is not created in the DOM until this method is called:
        tree.draw();
    }

	//Add a window onload handler to build the tree when the load
	//event fires.
    YAHOO.util.Event.addListener(window, "load", treeInit);

})();
function direciona(pagina) 
{
      var form = document.forms[0];
      form.action = pagina;
      form.submit();
}
</script>
<div id="emsg"><?php echo $emsg; ?></div>
<div id="msg"><?php echo $msg; ?></div>



<?php echo html::stylesheet('media/highlight/styles/default.css');?>
<?php echo html::stylesheet('media/highlight/styles/idea.css');?>
<?php echo html::script('media/highlight/highlight.js');?>
<?php echo html::script('media/highlight/languages/sql.js');?>
<script>
  hljs.tabReplace = '    ';
  hljs.initHighlightingOnLoad();
</script>
<div style="background-color: #99F">Codigo gerado:</div>
<pre><code class="sql"><?php echo $codigoGerado; ?></code></pre>


<h1>Lexemas</h1>
<hr>
<table border="0">
	<tr>
		<td valign="top">
<?php echo form::open('sintatico/analize');?>
<?php echo form::label('relacional', 'Codigo').'<br>';?>
<?php echo form::textarea('relacional', $relacional, "cols=60 rows=4").'<br>'; ?>
<?php echo form::submit('enviar', 'Analize Lexica', 'onclick="direciona(\'/kpsql/lexico/analize\')"')?>
<?php echo form::submit('enviar', 'Analize Sintatica', 'onclick="direciona(\'/kpsql/sintatico/analize\')"')?>
<?php echo form::submit('enviar', 'Geração de Codigo', 'onclick="direciona(\'/kpsql/gera_codigo/geracao\')"')?>
<?php echo form::close();?>

<div id="help">
Consultas Validas: <br>
projecao nome, idade (pessoa)<br />
selecao (pessoa) (nome='alguem')<br />
projecao nome, idade (selecao (pessoa) (nome='alguem'))<br />
projecao pessoa.nome, aluno.idade (selecao (pessoa cartesiano aluno) (pessoa.aluno_id=aluno.id))<br />
</div>
		</td>
		<td>
		<!-- Some style for the expand/contract section-->
<style>
#expandcontractdiv {border:1px dotted #dedede; background-color:#EBE4F2; margin:0 0 .5em 0; padding:0.4em;}
#treeDiv1 { background: #fff; padding:1em; margin-top:1em; }
</style>

<!-- markup for expand/contract links -->
<div id="expandcontractdiv">
	<a id="expand" href="#">Expandir</a>
	<a id="collapse" href="#">Esconder</a>
</div>
		<div id="treeDiv1">
		
		</div>
		</td>
	</tr>
</table>

<?php echo $rodape; ?>